package org.puremvc.scenelist.view {
	import org.puremvc.as3.multicore.interfaces.IMediator;
	import org.puremvc.as3.multicore.interfaces.INotification;
	import org.puremvc.as3.multicore.patterns.mediator.Mediator;
	import org.puremvc.scenelist.ApplicationFacade;
	import org.puremvc.scenelist.model.SceneListProxy;
		
	
	public class ApplicationMediator extends Mediator implements IMediator 
	{	
		
		public static const NAME:String = "ApplicationMediator";
		
		private var sceneXml : XML;

		public function ApplicationMediator(viewComponent:SceneList)
		{
			super(NAME, viewComponent);
		}
		
		
		
		override public function listNotificationInterests():Array
		{
			return[
				ApplicationFacade.SHOW_SCENE_LIST,
				ApplicationFacade.LOADING_COMPLETE
				];
		}
		
		
		override public function handleNotification(note : INotification):void
		{
			switch(note.getName())
			{
				case ApplicationFacade.LOADING_COMPLETE:
					// give the xml to the mxml.
					sceneXml =  SceneListProxy(facade.retrieveProxy(SceneListProxy.NAME)).getSceneXml();
					app.sceneList.dataProvider = sceneXml.scene; 
					break;
			}
			
		}

		
		protected function get app() : SceneList 
		{
			return viewComponent as SceneList;
		}

	}
}